package com.aaa.service.mht.impl;


import com.aaa.dao.mht.TMhtRecordMapper;
import com.aaa.entity.MyPage;
import com.aaa.entity.mht.TMhtMessage;
import com.aaa.entity.mht.TMhtRecord;
import com.aaa.service.mht.TMhtRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * (TMhtRecord)表服务实现类
 *
 */
@Service
public class TMhtRecordServiceImpl implements TMhtRecordService {
   @Autowired
   private TMhtRecordMapper tMhtRecordMapper;

    @Override
    public TMhtRecord checkrecord(TMhtRecord record) {
        TMhtRecord tMhtRecord = tMhtRecordMapper.selectOne(record);
        return tMhtRecord;
    }

    @Override
    public int insertRecord(TMhtRecord record) {
        record.setCreatetime(new Date());
        int i = tMhtRecordMapper.insert(record);
        System.out.println(record+"=================="+record.getId());
        return record.getId();
    }

    @Override
    public List<Map<String,Object>> getTjData() {

        return tMhtRecordMapper.getTjData();
    }

    @Override
    public PageInfo getTjData2(MyPage myPage, TMhtMessage tMhtMessage) {
        PageHelper.startPage(myPage.getPage(),myPage.getLimit());

        return new PageInfo(tMhtRecordMapper.getTjData2(tMhtMessage));
    }

    @Override
    public PageInfo getAll(MyPage myPage, TMhtRecord tMhtRecord) {
        PageHelper.startPage(myPage.getPage(), myPage.getLimit());
        List<TMhtRecord> tMhtRecords = tMhtRecordMapper.querAll(tMhtRecord);
        PageInfo pageInfo = new PageInfo(tMhtRecords);
        return pageInfo;
    }

    @Override
    public PageInfo getDetailMsg(MyPage myPage, Integer id) {
        PageHelper.startPage(myPage.getPage(), myPage.getLimit());
        List<Map<String,Object>> details = tMhtRecordMapper.getDetails(id);
        PageInfo pageInfo = new PageInfo(details);
        return pageInfo;
    }
}

